package com.ls.huawei;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        while(sc.hasNextLine()){
            String line = sc.nextLine();

            String line2 = sc.nextLine();
            char ch = line2.charAt(0);
            ch = (char)(ch | 32);

            int sum = 0;
            for(int i = 0; i < line.length(); i++){
                if((line.charAt(i) | 32) == ch){
                    sum++;
                }
            }
            System.out.println(sum);
        }


    }



}
